package org.needcoke.hs.okhttp;

import okhttp3.Interceptor;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.needcoke.hs.http.HttpInterceptor;
import org.needcoke.hs.http.Request;

import java.io.IOException;

public abstract class OkHttpInterceptor implements HttpInterceptor , Interceptor {

    @Override
    public abstract void intercept(Request request);
    @NotNull
    @Override
    public Response intercept(@NotNull Chain chain) throws IOException {
        OkHttpRequest request = new OkHttpRequest(chain.request());
        intercept(request);
        Response response = chain.proceed(request.getRequest());
        return response;
    }
}
